package se.citerus.dddsample.data;

import org.springframework.jdbc.core.JdbcTemplate;


public class CarrierMovementDataGenerator extends AbstractDataGenerator {

	public void loadCarrierMovementData(JdbcTemplate jdbcTemplate) {
	    String voyageSql =
	      "insert into Voyage (id, voyage_number) values (?, ?)";
	    Object[][] voyageArgs = {
	      {1,"0101"},
	      {2,"0202"},
	      {3,"0303"}
	    };
	    executeUpdate(jdbcTemplate, voyageSql, voyageArgs);

	    String carrierMovementSql =
	      "insert into CarrierMovement (id, voyage_id, departure_location_id, arrival_location_id, departure_time, arrival_time, cm_index) " +
	      "values (?,?,?,?,?,?,?)";

	    Object[][] carrierMovementArgs = {
	      // SESTO - FIHEL - DEHAM - CNHKG - JPTOK - AUMEL (voyage 0101)
	      {1,1,1,5,ts(1),ts(2),0},
	      {2,1,5,6,ts(1),ts(2),1},
	      {3,1,6,3,ts(1),ts(2),2},
	      {4,1,3,4,ts(1),ts(2),3},
	      {5,1,4,2,ts(1),ts(2),4},

	      // AUMEL - USCHI - DEHAM - SESTO - FIHEL (voyage 0202)
	      {7,2,2,7,ts(1),ts(2),0},
	      {8,2,7,6,ts(1),ts(2),1},
	      {9,2,6,1,ts(1),ts(2),2},
	      {6,2,1,5,ts(1),ts(2),3},

	      // CNHKG - AUMEL - FIHEL - DEHAM - SESTO - USCHI - JPTKO (voyage 0303)
	      {10,3,3,2,ts(1),ts(2),0},
	      {11,3,2,5,ts(1),ts(2),1},
	      {12,3,6,1,ts(1),ts(2),2},
	      {13,3,1,7,ts(1),ts(2),3},
	      {14,3,7,4,ts(1),ts(2),4}
	    };
	    executeUpdate(jdbcTemplate, carrierMovementSql, carrierMovementArgs);
	}
}

